package group6renderer.renderernode;

import java.util.ArrayList;

import group6renderer.Display;
import group6renderer.Visitor;

/** ClASS NAME: ListNode
 * DESCRIPTION: A class to deal with the indexing of lists
 * COLABORATORING CLASSES: TreeNode, ListIndexNode, Visitor, Display
 * @author jonnie
 */

public class ListNode extends TreeNode {
    
    
	private ArrayList<ListIndexNode> indexNodes;
	
	/** 
	 * A method to add an index node to the array list of nodes
	 */
    public int addIndexNode(ListIndexNode indexNode)
    {
    	indexNodes.add(indexNode);
    	return indexNodes.indexOf(indexNode)+1;
    	
    }
	
    /**
	 * A Constructor to initialise the fields of a new ListNode.
	 */
    public ListNode(String name)
    {
    	indexNodes= new ArrayList<ListIndexNode>();
    	this.name=name;
    }
    
    
    /** 
     * A method to return whether this Node is a LeafNode
     * @return true if this node has a closing tag and false otherwise
     */
    public boolean isLeaf()
    {
	return false;
    }

    /** 
     * A method to return whether this Node has a closing tag
     * @Override
     * @return true if this node has a closing tag and false otherwise
     */
    public boolean hasClosing()
    {
    	return true;
    }

    /** 
     * A method to accept a Visitor so that its method can be called to visit this node. 
     * @param theVisitor references the Visitor interface
     * @Override
     */
	public void accept(Visitor theVisitor) {
		theVisitor.visit(this);
	} 

	/** 
     * A method overriding the abstract method in TreeNode. It adjusts the properties of the State class according to the type of node
     * concerned.  
     * @param disp the Display object of the project (there is only one)
     * @Override
     */
    public void drawNode(Display disp)
    {

    }
    
    /** 
     * A method to return a new copy of this node.
     * @Override
     * @return a new instance of this node with the original name
     */
    public TreeNode copy()
    {
	return new ListNode(name);
    }
    
   
    
}